#ifndef _DSWTCPSERVER_BASE_H
#define _DSWTCPSERVER_BASE_H
#include <libbase/dswbase.h>

class CDswtcpserver_base : public CDswbase
{
public:
	CDswtcpserver_base(LPST_ENV_T pEnv, int nPort);
	virtual ~CDswtcpserver_base();
public:
	int GetServerPort(){return m_nPort;};
protected:
	static void cb_OnAccept(struct evconnlistener *listener, evutil_socket_t fd, struct sockaddr *address, int socklen,
		void *ctx){((CDswtcpserver_base*)ctx)->OnAccept(fd, address, socklen);};
	virtual void OnAccept(evutil_socket_t fd, struct sockaddr *address, int socklen){};
	static void cb_OnAcceptError(struct evconnlistener *listener, void *ctx){((CDswtcpserver_base*)ctx)->OnAcceptError(listener);};
	void OnAcceptError(struct evconnlistener *listener);
private:
	void CreateServer(int nPort);
protected:
	struct evconnlistener *m_pListener;
	int m_nPort;
};

#endif

